package com.glodon.paas.document.biz;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.glodon.paas.document.DocumentBaseIT;
import com.glodon.paas.document.constant.DocumentConstant;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(value = { "classpath:test-document-biz.xml", "classpath:paas-document-dao-mysql.xml", })
@Ignore
public class ShareBizMySqlIT extends DocumentBaseIT {

    @Autowired
    private ShareBiz biz;

    @Before
    public void setup() {
        if (!initedData) {
            super.setup();
            createShare(1);
            initedData = true;
        }
    }

    // @Test
    // public void testIsSharedForUser(){
    // assertTrue(biz.isSharedForUser(userId, fileId1));
    // }

    @Test
    public void testIsSharedFile() {
        removeShare(1);
        assertFalse(biz.isSharedFile(fileId1));
        createShare(1);
        assertTrue(biz.isSharedFile(fileId1));
    }

    @Test
    public void testGetSharesByMe() {
        assertNotNull(biz.getSharesByMe(ownerId, null, DocumentConstant.SHARE_TYPE_SHARED));
    }

    @Test
    public void testGetSharesForMe() {
        assertNotNull(biz.getSharesForMe(userId, null));
    }

    @Test
    public void testGetShareForme() {
        assertNotNull(biz.getShareForMe(userId, fileId1));
    }

    @Test
    public void testGetNavigation() {
        assertNotNull(biz.getNavigation(userId, fileId1));
    }

    @Test
    public void testGetShareCount() {
        assertTrue(biz.getShareCount(fileId1) == 1);
    }

    @Test
    public void removeData() {
        if (initedData) {
            cleanFile();
            cleanShare();
            initedData = false;
        }
    }
}
